# name : dplyr&purrr rowwise.lag.func
# key : rowwise.lag.func
# key : dplyr.rowwise.lag.func
# contributor: Shuguang Sun
# --
${1:fill_in} <- function(prev, new, growth = 0.03) {
  if_else(!is.na(new), new, prev * (1 + growth))
}

${2:dt} |>
  mutate(${3:newvar} = purrr::accumulate(${4:var}, $1))